import pytest
from config import PHONE
from tool import DriverTools as Dr

from pages.p1_register_page import Register
from pages.p2_client_login_page import ClientLogin
from pages.p3_admin_login_page import AdminLogin


@pytest.fixture(scope="function")
def register_operation():
    reg = Register(driver=Dr.get_driver())
    reg.open_url()
    yield reg
    Dr.quit_driver()


@pytest.fixture(scope="function")
def register_login_other_page_operation():
    re = Register(driver=Dr.get_driver())
    re.open_url()
    re.register(PHONE, "li123456", "8888", "666666")
    yield re.driver
    Dr.quit_driver()


@pytest.fixture(scope="function")
def client_login_operation():
    cl = ClientLogin(driver=Dr.get_driver())
    cl.open_url()
    yield cl
    Dr.quit_driver()


@pytest.fixture(scope="function")
def client_login_other_page_operation():
    cl = ClientLogin(driver=Dr.get_driver())
    cl.open_url()
    cl.client_login('13612342289', "li123456")
    yield cl.driver
    Dr.quit_driver()


@pytest.fixture(scope="function")
def admin_login_operation():
    cl = AdminLogin(driver=Dr.get_driver())
    cl.open_url()
    yield cl
    Dr.quit_driver()


@pytest.fixture(scope="function")
def admin_login_other_page_operation():
    cl = AdminLogin(driver=Dr.get_driver())
    cl.open_url()
    cl.admin_login_operation('admin', 'HM_2025_test', '8888')
    yield cl.driver
    # Dr.quit_driver()
